
package com.insigma.business.qrcode.soldier.service.impl;

import cn.hutool.core.collection.CollectionUtil;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.insigma.business.qrcode.soldier.dto.SoldierDTO;
import com.insigma.business.qrcode.soldier.util.ResponseFilterUtil;


import java.util.List;


public class SoldierResponseFilter {

    private SoldierResponseFilter(){}

    
    private static final String[] SHARED_RESPONSE_ITEM = {"id",
                                                          "avatarId",
                                                          "avatarRelativeUri",
                                                          "accountName",
                                                          "mobile",
                                                          "serviceStationId",
                                                          "status",
                                                          "lastLoginDatetime",
                                                          "lastLoginIp",
                                                          "type",
                                                          "registerSource",
                                                          "registerTerminalType",
                                                          "registerLatitude",
                                                          "registerLongitude"
                                                          };

    
    private static final String[] GET_RESPONSE_ITEM = {"id",
                                                       "avatarId",
                                                       "avatarRelativeUri",
                                                       "accountName",
                                                       "mobile",
                                                       "serviceStationId",
                                                       "status",
                                                       "lastLoginDatetime",
                                                       "lastLoginIp",
                                                       "type",
                                                       "registerSource",
                                                       "registerTerminalType",
                                                       "registerLatitude",
                                                       "registerLongitude"
                                                       };

    
    private static final String[] SEARCH_RESPONSE_ITEM = {"id",
                                                          "avatarId",
                                                          "avatarRelativeUri",
                                                          "accountName",
                                                          "mobile",
                                                          "serviceStationId",
                                                          "status",
                                                          "lastLoginDatetime",
                                                          "lastLoginIp",
                                                          "type",
                                                          "registerSource",
                                                          "registerTerminalType",
                                                          "registerLatitude",
                                                          "registerLongitude"
                                                          };

    
    public static JSONArray filterSearch(final List<SoldierDTO> soldierDTOList ){
        if(CollectionUtil.isEmpty(soldierDTOList)){
            return null;
        }
        return ResponseFilterUtil.filterList(soldierDTOList, SEARCH_RESPONSE_ITEM);
    }

    
    public static JSONObject filterGet(final SoldierDTO soldierDTO){
        if(soldierDTO==null){
            return null;
        }
        return ResponseFilterUtil.filterObj(soldierDTO, GET_RESPONSE_ITEM);
    }


}
